<?php
$this->breadcrumbs=array(
	'Admin Panel'=>$this->createUrl( '/adminpanel'),
	'Tenant'=>array('/adminpanel/tenant/'),
	$model->idTenant=>array('/adminpanel/tenant/view','id'=>$model->idTenant),
	'View',
);


$this->menu=array(
	
	array('label'=>'Edit Occupancy', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'Edit MoveOut', 'url'=>array('/adminpanel/moveout/update', 'id'=>$model->moveouts->id)),
	//array('label'=>'Delete MoveOut', 'url'=>'#', 'linkOptions'=>array('submit'=>array('/adminpanel/moveout/delete','confirm'=>'Are you sure you want to delete this MoveOut?'))),
	array('label'=>'Delete MoveOut', 'url'=>'#', 'linkOptions'=>array('submit'=>array('/adminpanel/moveout/delete','returnUrl'=>array('/adminpanel/occupancy/view','id'=>$model->id),'id'=>$model->moveouts->id),'confirm'=>'Are you sure you want to delete this MoveOut?')),
	array('label'=>'Edit Lease violations', 'url'=>array('/adminpanel/leaseviolations/update', 'id'=>$model->leaseviolations->id)),
	array('label'=>'Delete Lease violations', 'url'=>'#', 'linkOptions'=>array('submit'=>array('/adminpanel/leaseviolations/delete','returnUrl'=>array('/adminpanel/occupancy/view','id'=>$model->id),'id'=>$model->leaseviolations->id),'confirm'=>'Are you sure you want to delete this Lease violations?')),
	array ('label'=>'Add Security Deposits ', 'url'=>array('/adminpanel/payments/create','oid'=>$model->id,'typ'=>'Security Deposits' , 'rurl'=>Yii::app()->request->requestUri)),
	array ('label'=>'Add Payments ', 'url'=>array('/adminpanel/payments/create','oid'=>$model->id,'typ'=>'Payment' , 'rurl'=>Yii::app()->request->requestUri)),
	array ('label'=>'Add Fees ', 'url'=>array('/adminpanel/payments/create','oid'=>$model->id,'typ'=>'Fee' , 'rurl'=>Yii::app()->request->requestUri)),
);
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/assets/js/tabs.js');
?>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/tabs.css" media="screen, projection" />


<h1><?php echo $model->idTenant0->iduser0->LastName .' > '.$model->idRentalProperty0->AddressOne .':'.$model->idRentalUnit0->UnitNumber; ?></h1>

<ul class="tabs">
    <li><a href="#tab1">Overview</a></li>
    <li><a href="#tab2">Move Out Detail</a></li>
    <li><a href="#tab3">Lease Violation</a></li>
    <li><a href="#tab4">Security Deposits</a></li>
    <li><a href="#tab5">Payments & Fees</a></li>
</ul>

<div class="tab_container">

<div id="tab1" class="tab_content">
<br>
<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		array(
			'label' => 'Tenant Name',
			'type'=>'raw',
			'value' =>CHtml::link(CHtml::encode($model->idTenant0->iduser0->FirstName.' '.$model->idTenant0->MiddleInitial.' '.$model->idTenant0->iduser0->LastName),
                                 array('/adminpanel/management/view','id'=>$model->idTenant)),
		),
		array(
			'label' => 'Rental Property',
			'type'=>'raw',
			'value' =>CHtml::link(CHtml::encode($model->idRentalProperty0->AddressOne.''.$model->idRentalProperty0->AddressTwo),
                                 array('/adminpanel/rentalproperty/view','id'=>$model->idRentalProperty0->id)),
		),
		array(
			'label' => 'Rental Unit Number',
			'type'=>'raw',
			'value' =>CHtml::link(CHtml::encode($model->idRentalUnit0->UnitNumber),
                                 array('/adminpanel/rentalproperty/view','id'=>$model->idRentalProperty0->id)),
		),
		'MoveInDate',
		'SoftwareTenantNumber',
		'MoveOutDate',
		'LeaseEndDate',
		'Occupancycol',
		array(
			'label' => 'Month To Month Tenancy',
			'value' => ($model->MonthToMonthTenancy == 1)?'Yes':'No',
		),
	),
)); ?>
<br>
</div>
 
<div id="tab2" class="tab_content">
<?php if(Moveout::model()->exists('idOccupancy=:o_id', array(':o_id'=>$model->id))) {?>

<style>
#screenshot{
	position:absolute;
	border:1px solid #ccc;
	background:#333;
	padding:5px;
	display:none;
	color:#fff;
	}
#preview{
	position:absolute;
	border:1px solid #ccc;
	background:#333;
	padding:5px;
	display:none;
	color:#fff;
	}
/*  */
</style>
<?php 

//Yii::app()->clientScript->registerCoreScript('jquery'); 
//Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/assets/js/main.js');
//Yii::app()->clientScript->scriptMap=array(Yii::app()->baseUrl.'/resources/js/hoverIntent.js'=>Yii::app()->baseUrl.'/resources/js/main.js');

Yii::import('application.extensions.jqPrettyPhoto');
jqPrettyPhoto::addPretty('.screenshot ',jqPrettyPhoto::PRETTY_GALLERY,jqPrettyPhoto::THEME_FACEBOOK);

$photolinks='';
if($model->moveouts->Photos){
	$photos=explode(',', $model->moveouts->Photos);
	foreach ($photos as $photo)
	{
		//$photolinks=CHtml::link(CHtml::encode($photo), array('#'),array('class'=>'screenshot','rel'=>Yii::app()->request->baseUrl.'/assets/uploads/photos/'.$photo)).'<br>'.$photolinks;
		//$photolinks= CHtml::link(CHtml::image(Yii::app()->request->baseUrl.'/assets/uploads/photos/'.$photo,'gallery thumbnail',array('width'=>'60px','height'=>'60px')), array('/assets/uploads/photos/'.$photo),array('class'=>'screenshot','rel'=>Yii::app()->request->baseUrl.'/assets/uploads/photos/'.$photo)).' '.$photolinks;
		//Helper::getImageSize(Yii::app()->request->baseUrl.'/assets/uploads/photos/'.$photo);
		
		$photolinks=  '<a class = "screenshot" href="'.Yii::app()->request->baseUrl.'/assets/uploads/photos/'.$photo.'">'.CHtml::image(Yii::app()->request->baseUrl.'/assets/uploads/photos/'.$photo,'MoveOut Photos',array('width'=>'60px','height'=>'60px')).'</a>'.' '.$photolinks;
		//print_r(getimagesize(Yii::app()->request->baseUrl.'/assets/uploads/photos/'.$photo));
	}
	
}
$this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		array(
			'label' => 'Pet Comply',
			'value' => ($model->moveouts->PetComply == 1)?'Yes':'No',
		),
		array(
			'label' => 'Rules',
			'value' => ($model->moveouts->Rules == 1)?'Yes':'No',
		),
		array(
			'label' => 'Quiet Enjoyment',
			'value' => ($model->moveouts->QuietEnjoyment == 1)?'Yes':'No',
		),
		array(
			'label' => 'Smoker',
			'value' => ($model->moveouts->Smoker == 1)?'Yes':'No',
		),
		array(
			'label' => 'Pet Owner',
			'value' => ($model->moveouts->PetOwner == 1)?'Yes':'No',
		),
		array(
			'label' => 'House Keeping',
			'value' => ($model->moveouts->HouseKeeping == 1)?'Yes':'No',
		),
		array(
			'label' => 'Damages',
			'value' => ($model->moveouts->Damages == 1)?'Yes':'No',
		),
		array(
			'label' => 'Damage Total',
			'value' => ($model->moveouts->DamageTotal)?'$'.$model->moveouts->DamageTotal:'-',
		),
		array(
			'label' => 'Security Deposit Returned',
			'value' => ($model->moveouts->SecurityDepositReturned == 1)?'Yes':'No',
		),
		'moveouts.AskedToLeave',
		'moveouts.EvictionFiled',
		'moveouts.EvictionGranted',
		array(
			'label' => 'Rent Again',
			'value' => ($model->moveouts->RentAgain == 1)?'Yes':'No',
		),
		array(
			'label' => 'Non Lease Occupants',
			'value' => ($model->moveouts->NonLeaseOccupants == 1)?'Yes':'No',
		),
		
		'moveouts.UnpaidObligations',
		'moveouts.DateSatisfiedDebt',
		'moveouts.Comments',
		array(
			'label' => 'Photos',
			'type' 	=> 'raw',
			'value' => ($photolinks == '')?'-':$photolinks,
		),
		'moveouts.ReportDate',
	),
));

}
else 
echo CHtml::link(CHtml::encode('Add Move Out Detail' ), array('/adminpanel/moveout/create','oid'=>$model->id)); 
?>
</div>

<div id="tab3" class="tab_content">
<?php if(Leaseviolations::model()->exists('idOccupancy=:o_id', array(':o_id'=>$model->id)))
{
	$this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		
		'leaseviolations.LeaseViolationShortDescription',
		'leaseviolations.LeaseViolationDateOfOccurance',
		
		
	),
));
} else 
echo CHtml::link(CHtml::encode('Add Lease Violation Detail' ), array('/adminpanel/LeaseViolations/create','oid'=>$model->id,'tid'=>$model->idTenant)); 
?>
</div>
<div id="tab4" class="tab_content">
<?php $this->renderPartial(
	'/payments/_SecurityDeposits',
	array(
	'oid'=>$model->id
	)
	); ?>
</div>
<div id="tab5" class="tab_content">
<?php $this->renderPartial(
	'/payments/_PaymentsFees',
	array(
	'oid'=>$model->id
	)
	); ?>

</div>
</div>